home *** CD-ROM | disk | FTP | other *** search
/ Computer Inter@ctive 17 / Computer Interactive cdrom 17 - gen 99.iso / ZDNETIT / CONTENT / OPTIVDOS.ZIP / INCLUDE.ZIP / VISTD.H < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-21  |  6.8 KB  |  182 lines

  1. /*  VIstd.h
  2.  
  3.   vector management functions for data type "int".
  4.  
  5.   Copyright (c) 1996-1998 by Martin Sander
  6.   All Rights Reserved.
  7. */
  8.  
  9. #ifndef __VISTD_H
  10. #define __VISTD_H
  11.  
  12. #if !defined( __VECLIB_H )
  13.    #include <VecLib.h>
  14. #endif
  15.  
  16. #ifdef __cplusplus
  17.    extern "C" {
  18. #endif
  19.  
  20. /***********  Generation of Arrays and Vectors  *************************/
  21.  
  22. iVector  __vf  VI_vector( ui size );
  23. iVector  __vf  VI_vector0( ui size );
  24.  
  25. /***************  Addressing single vector elements ******************/
  26.  
  27. int _VFAR * VI_Pelement( iVector X, ui n );
  28.       /* returns a pointer to the n'th element of X. For the memory model
  29.          HUGE, the pointer is normalized. */
  30. #define VI_element( X, n )  (*VI_Pelement( X, n ))
  31.  
  32. /****************** Initialization  ******************************/
  33.  
  34. void  __vf  VI_equ0( iVector X, ui size );
  35. void  __vf  VI_equC( iVector X, ui size, int C );
  36. void  __vf  VI_equV( iVector Y, iVector X, ui size );
  37. void  __vf  VIo_ramp( iVector X, ui size, int Start, int Rise );
  38. #ifdef V_trapIntError
  39.     #define VI_ramp    VIo_ramp
  40. #else
  41.     void  __vf  VI_ramp( iVector X, ui size, int Start, int Rise );
  42. #endif
  43. long  __vf  VI_random( iVector X, ui size, long seed,
  44.                        int MinVal, int MaxVal );  /*  returns new seed */
  45.  
  46.  
  47. /************** Data-type interconversions  ***************************/
  48.  
  49. void  __vf   V_SItoI(  iVector  Y, siVector X, ui size );  /* up-conversion */
  50. void  __vf   V_ItoLI(  liVector Y, iVector  X, ui size );
  51. void  __vf   V_ItoQI(  qiVector Y, iVector  X, ui size );
  52.  
  53. void  __vf   Vo_ItoU( uVector Y, iVector X, ui size );  /* signed-unsigned */
  54. void  __vf   Vo_UtoI( iVector Y, uVector X, ui size );
  55.  
  56. void  __vf   Vo_ItoSI( siVector Y, iVector  X, ui size ); /* down-conversion */
  57. void  __vf   Vo_LItoI( iVector  Y, liVector X, ui size );
  58. void  __vf   Vo_QItoI( iVector  Y, qiVector X, ui size );
  59. #ifdef V_trapIntError
  60.     #define V_ItoU    Vo_ItoU
  61.     #define V_UtoI    Vo_UtoI
  62.     #define V_ItoSI   Vo_ItoSI
  63.     #define V_LItoI   Vo_LItoI
  64.     #define V_QItoI   Vo_QItoI
  65. #else
  66.     void  __vf   V_ItoU( uVector Y, iVector X, ui size );
  67.     void  __vf   V_UtoI( iVector Y, uVector X, ui size );
  68.     void  __vf   V_ItoSI( siVector Y, iVector  X, ui size );
  69.     void  __vf   V_LItoI( iVector  Y, liVector X, ui size );
  70.     void  __vf   V_QItoI( iVector  Y, qiVector X, ui size );
  71. #endif
  72.  
  73. void  __vf   V_ItoF(   fVector Y, iVector  X, ui size );
  74. void  __vf   V_ItoD(   dVector Y, iVector  X, ui size );
  75. #ifdef __BORLANDC__
  76.     void  __vf   V_ItoE(   eVector Y, iVector  X, ui size );
  77. #else  /* no 80-bit IEEE reals with Visual C++ */
  78.     #define V_ItoE V_ItoD
  79. #endif
  80.  
  81. /************** Index-oriented manipulations ***************************/
  82.  
  83. void  __vf  VI_rev( iVector Y, iVector X, ui size );
  84. #ifdef V_HUGE
  85.     void  __vf  VI_rotate( iVector Y, iVector X, ui size, long pos );
  86. #else
  87.     void  __vf  VI_rotate( iVector Y, iVector X, ui size, int pos );
  88. #endif
  89.  
  90. void  __vf  VI_delete( iVector X, ui size, ui pos );
  91. void  __vf  VI_insert( iVector X, ui size, ui pos, int C );
  92.  
  93. void  __vf  VI_sort( iVector Y, iVector X, ui size, int dir );
  94. void  __vf  VI_sortind( uiVector Ind, iVector X, ui size, int dir );
  95.  
  96. void  __vf  VI_subvector( iVector Y, ui sizey, iVector X, int samp );
  97. void  __vf  VI_subvector_equC( iVector Y, ui subsz, unsigned samp, int C );
  98. void  __vf  VI_subvector_equV( iVector Y, ui subsz, unsigned samp, iVector X );
  99.  
  100. void  __vf  VI_indpick( iVector Y, uiVector Ind, ui sizey, iVector X );
  101. void  __vf  VI_indput(  iVector Y, iVector X, uiVector Ind, ui sizex );
  102.  
  103. ui    __vf  VI_searchC( iVector XTab, ui size, int C, int mode );
  104. void  __vf  VI_searchV( uiVector Ind, iVector X, ui sizex,
  105.                         iVector Tab, ui sizetab, int mode );
  106.  
  107.  
  108. /********************   One-dimensional Vector Operations  ********/
  109.  
  110. int  __vf  VIo_sum( iVector X, ui size );
  111. void __vf  VIo_runsum( iVector Y, iVector X, ui size );
  112. #ifdef V_trapIntError
  113.     #define VI_sum     VIo_sum
  114.     #define VI_runsum  VIo_runsum
  115. #else
  116.     int  __vf  VI_sum( iVector X, ui size );
  117.     void __vf  VI_runsum( iVector Y, iVector X, ui size );
  118. #endif
  119. int    __vf  VI_max( iVector X, ui size );
  120. int    __vf  VI_min( iVector X, ui size );
  121. int    __vf  VI_maxind( ui _VFAR *Ind, iVector X, ui size );
  122. int    __vf  VI_minind( ui _VFAR *Ind, iVector X, ui size );
  123. void   __vf  VI_runmax( iVector Y, iVector X, ui size );
  124. void   __vf  VI_runmin( iVector Y, iVector X, ui size );
  125. double __vf  VI_fsum( iVector X, ui size );
  126. double __vf  VI_mean( iVector X, ui size );
  127.  
  128. int    __vf  VI_iselementC( iVector Tab, ui size, int  C );
  129. ui     __vf  VI_iselementV( iVector Y, iVector X, ui sizex,
  130.                              iVector Tab, ui sizetab );
  131.  
  132.  
  133. /************************ Input / Output ******************************/
  134.  
  135. void  __vf   V_ifprint(  FILE _VFAR *stream, void _VFAR *X, ui size,
  136.                   unsigned nperline, unsigned linewidth, unsigned vers );
  137. #define VI_fprint( st, x, sz, npl, lw )  \
  138.              V_ifprint(  st, (void _VFAR *)(x), sz, npl, lw, 4 )
  139.  
  140. #if !(defined _Windows || defined _WINDOWS)
  141.    void __vf  V_icprint(  void _VFAR *X, ui size, unsigned nperline, unsigned vers );
  142.    #define VI_cprint( x, sz, npl ) \
  143.              V_icprint( (void _VFAR *) (x), sz, npl, 4 )
  144. #endif
  145. #define VI_print( x, sz, npl )  \
  146.              V_ifprint(  stdout, (void _VFAR *)(x), sz, npl, 80, 4 )
  147.  
  148. void  __vf   V_setRadix( int radix );
  149.            /* radix to be assumed by all whole-number read functions V??_read */
  150. void  __vf   VI_read( iVector X, ui size, FILE _VFAR *stream );
  151. void  __vf   VI_write( FILE _VFAR *stream, iVector X, ui size );
  152. void  __vf   VI_nread( unsigned n, ui size, FILE _VFAR *stream, ... );
  153. void  __vf   VI_nwrite( FILE _VFAR *stream, unsigned n, ui size, ... );
  154. void  __vf   VI_setWriteFormat( char _VFAR *FormatString );
  155.                                             /* for VI_write and VI_nwrite */
  156. void  __vf   VI_setWriteSeparate( char _VFAR *SepString ); /* for VI_write */
  157. void  __vf   VI_setNWriteSeparate( char _VFAR *SepString ); /* for VI_nwrite */
  158. #ifdef V_HUGE
  159.     void  __vf   VI_store(  FILE _VFAR *stream, iVector X, ui size );
  160.     void  __vf   VI_recall( iVector X, ui size, FILE _VFAR *stream );
  161. #else
  162.     #ifdef __cplusplus
  163.          void  inline VI_store( FILE _VFAR *stream, iVector X, ui size )
  164.          {    fwrite( X, sizeof(int), size, stream ); 
  165.          }
  166.          void  inline VI_recall( iVector X, ui size, FILE _VFAR *stream )
  167.          {    fread(  X, sizeof(int), size, stream );
  168.          }
  169.     #else
  170.         #define VI_store( str, X, sz )  \
  171.                      fwrite( X, sizeof(int), sz, str )
  172.         #define VI_recall( X, sz, str ) \
  173.                      fread(  X, sizeof(int), sz, str )
  174.     #endif
  175. #endif      /* VI_store, VI_recall in binary format */
  176.  
  177. #ifdef __cplusplus
  178. }
  179. #endif
  180.  
  181. #endif   /*  __VISTD_H    */
  182.